package com.spring.service.impl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.spring.dao.IUserDao;
import com.spring.model.User;
import com.spring.service.IUserService;

@Service(value="userServiceImpl")
public class UserServiceImpl implements IUserService {
	
	private IUserDao userDaoImpl;
	
	
	
	public IUserDao geUserDaoImpl() {
		return userDaoImpl;
	}
	@Resource(name="userDaoImpl")
	public void seUserDaoImpl(IUserDao userDaoImpl) {
		this.userDaoImpl = userDaoImpl;
	}

	@Override
	public void addUser(User user)  {
		// TODO Auto-generated method stub
		userDaoImpl.save(user);
	}

	@Override
	public void updateUser(User user)  {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void deleteUser(int id)  {
		// TODO Auto-generated method stub
		
	}

	@Override
	public User geUserById(int id)  {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public List<User> geUserList()  {
		// TODO Auto-generated method stub
		return userDaoImpl.findAll();
	}

	@Override
	public User geUserByName(String name)  {
		List list = userDaoImpl.findByName(name);
		return list==null || list.size() == 0 ? null : (User)list.get(0);
	}

}
